#include "gamehall.h"
#include "ui_gamehall.h"
#include "gameselect.h"



GameHall::GameHall(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::GameHall)
{
    ui->setupUi(this);

    this->setFixedSize(1200,800);
    this->setWindowTitle("贪吃蛇大作战");
    this->setWindowIcon(QIcon(":res/ico.png"));

    //设计 游戏大厅  开始游戏 按钮
    QPushButton* strBtn = new QPushButton(this);
    strBtn->move(1200 * 0.4,800 * 0.8);
    strBtn->setText("开始游戏");
    //strBtn->set
    QFont font("华文行楷",40);
    strBtn->setFont(font);
    strBtn->setStyleSheet("QPushButton{border:0px;}");

    //点击按钮
    GameSelect *gameSelect = new GameSelect;
    connect(strBtn,&QPushButton::clicked,[=](){
        this->close();
        gameSelect->setGeometry(this->geometry());
        gameSelect->show();

        //点击 音效
        QSound::play(":res/clicked.wav");
    });

}

GameHall::~GameHall()
{
    delete ui;
}

void GameHall::paintEvent(QPaintEvent *event)
{
    //实例化绘画对象
    QPainter painter(this);
    //实例化绘画设备
    QPixmap pix(":res/game_hall.jpg");
    //画面编辑
    painter.drawPixmap(0,0,this->width(),this->height(),pix);
}

